from rest_framework.mixins import ListModelMixin
from utils.common_response import APIResponse
from rest_framework.viewsets import ModelViewSet


class CommonListModelMixin(ListModelMixin):
    def list(self, request, *args, **kwargs):
        res = super().list(request, *args, **kwargs)
        return APIResponse(result=res.data)


class CommonModelViewSet(ModelViewSet):
    def list(self, request, *args, **kwargs):
        res = super().list(request, *args, **kwargs)
        return APIResponse(data=res.data)

    def create(self, request, *args, **kwargs):
        super().create(request, *args, **kwargs)
        return APIResponse()

    def retrieve(self, request, *args, **kwargs):
        res = super().retrieve(request, *args, **kwargs)
        return APIResponse(data=res.data)

    def update(self, request, *args, **kwargs):
        super().update(request, *args, **kwargs)
        return APIResponse()

    def destroy(self, request, *args, **kwargs):
        super().destroy(request, *args, **kwargs)
        return APIResponse()
